//package com.zyb.transaction.aop;
//
//
//import TransactionUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.AfterThrowing;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
///**
// * 声明式事务
// * ｛使用的是AOP + 编程式事务（TransactionUtils）来实现｝
// */
//@Slf4j
//@Aspect     //标注为切面类
//@Component  //给spring管理
//public class TransactionAop {
//
//    @Autowired
//    private TransactionUtils transactionUtils;
//
//    @Around("pointcut()")
//    public void around(ProceedingJoinPoint joinpoint) throws Throwable {
//        log.info("@Around 环绕通知前开启事务");
//        transactionUtils.begin();
//        joinpoint.proceed();
//        log.info("@Around 环绕通知后提交事务");
//        transactionUtils.commit();
//    }
//
//    @AfterThrowing(value = "pointcut()", throwing = "ex")
//    public void afterThrowing(Exception ex) {
//        log.info("@AfterThrowing 抛出异常,执行事务的回滚");
//        //获取当前事务对象，并回滚事务
//        transactionUtils.rollback();
//    }
//
//    @Pointcut("execution(* UserServiceImpl.add(..))")
//    public void pointcut() {
//    }
//}
